package com.dao.imp;

import java.util.List;
import org.hibernate.Query;
import com.dao.NoticeDao;
import com.dao.core.DaoBaseImp;
import com.page.PageDiv;
import com.pojo.Notice;

public class NoticeDaoImp extends DaoBaseImp<Notice> implements NoticeDao{

	@Override
	public PageDiv<Notice> getAllNoticebypage(int offSet, int pageSize) {
		if(offSet>=0&&pageSize>0)
		{
			String hql="from Notice";
			Query q=getSession().createQuery(hql);
			q.setMaxResults(pageSize);
			q.setFirstResult(offSet);
			List<Notice> list=q.list();
			int totalCount=this.getCountQuery(hql);
			return new PageDiv<Notice>(offSet,pageSize,totalCount,list);
		}
			
		else
			return new PageDiv<Notice>();
	}
	
}
